package com.atguigu.eduservice.controller;

import com.atguigu.baseservice.result.R;
import com.atguigu.eduservice.service.EduSubjectService;
import com.atguigu.eduservice.vo.SubjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程分类列表
 * </p>
 *
 * @author dayouzi
 * @since 2022-09-18
 */
@Api(description = "课程分类列表")
@RestController
@RequestMapping("/edu/subject")
@CrossOrigin
public class EduSubjectController {

    @Autowired
    private EduSubjectService eduSubjectService;

    @ApiOperation(value = "课程分类列表展示")
    @GetMapping("/list")
    public R getNestedList(){
        List<SubjectVo> subjectNestedVoList = eduSubjectService.getNestedList();
        return R.ok().data("items", subjectNestedVoList);
    }


    @ApiOperation(value = "Excel批量导入课程分类")
    @PostMapping("/addSubject")
    public R addSubject(MultipartFile file) {
        eduSubjectService.importSubject(file, eduSubjectService);
        return R.ok();
    }


}
